<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>{$siteTitle}</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
       <link rel="stylesheet" href="__PUBLIC__/admin/wx/css/default.css">
        <script type="text/javascript" src="__PUBLIC__/admin/wx/js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/wx/js/jquery.form.js"></script>
        <link rel="stylesheet" href="__PUBLIC__/admin/themes/default/default.css" />
		<link rel="stylesheet" href="__PUBLIC__/admin/plugins/code/prettify.css" />
		<script charset="utf-8" src="__PUBLIC__/admin/kindeditor-all-min.js"></script>
		<script charset="utf-8" src="__PUBLIC__/admin/lang/zh_CN.js"></script>
		<script charset="utf-8" src="__PUBLIC__/admin/plugins/code/prettify.js"></script>
		<style type="text/css">
			.demo{width:620px; margin:30px auto}
			.demo p{line-height:32px}
			.btnfile{position: relative;overflow: hidden;margin-right: 4px;display:inline-block;*display:inline;padding:4px 10px 4px;font-size:14px;line-height:18px;*line-height:20px;color:#fff;text-align:center;vertical-align:middle;cursor:pointer;background-color:#5bb75b;border:1px solid #cccccc;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
			.btnfile input {position: absolute;top: 0; right: 0;margin: 0;border: solid transparent;opacity: 0;filter:alpha(opacity=0); cursor: pointer;}
			.progress { position:relative; margin-left:100px; margin-top:-24px; width:200px;padding: 1px; border-radius:3px; display:none}
			.bar {background-color: green; display:block; width:0%; height:20px; border-radius: 3px; }
			.percent { position:absolute; height:20px; display:inline-block; top:3px; left:2%; color:#fff }
			.files{height:22px; line-height:22px; margin:10px 0}
			.delimg{margin-left:20px; color:#090; cursor:pointer}
			.place{height:40px; background:url(__PUBLIC__/admin/images/righttop.gif) repeat-x;}
			.place span{line-height:40px; font-weight:bold;float:left; margin-left:12px;}
			.placeul li{float:left; line-height:40px; padding-left:7px; padding-right:12px; background:url(__PUBLIC__/admin/images/rlist.gif) no-repeat right;}
			.placeul li:last-child{background:none;}
		</style>
    </head>
    <body>	
    	<div class="place">
		    <span>位置：</span>
		    <ul class="placeul">
		    	<li>首页</li>
		    	<li>编辑单图文素材</li>
		    </ul>
		</div>
        <div class="col_main">
        	<form action="{:U('editNewsImage',array('news_key'=>$one_news_images['news_key']))} " method="post">
        	<input type="hidden" name="id" id="id" value="{$one_news_images.id}"/>
            <div class="main_bd">
                <div class="media_preview_area">        
                    <div class="appmsg  editing">            
                        <div id="js_appmsg_preview" class="appmsg_content">                                            
                            <div id="appmsgItem1" class="js_appmsg_item">
                                <h4 class="appmsg_title"><span id="new_title">{$one_news_images.news_title}</span></h4>
                                <div class="appmsg_info">
                                    <em class="appmsg_date">{$one_news_images.news_time}</em>
                                </div>
                                <div class="appmsg_thumb_wrp">
                                    <img class="js_appmsg_thumb appmsg_thumb" id="new_img_default" style="display: block;" src="{$one_news_images.news_img_path}">
                                    <i class="appmsg_thumb default" style="display: none;">封面图片</i>
                                </div>
                                <p class="appmsg_desc">{$one_news_images.news_zhaiyao}</p>
                            </div>
                        </div>                    
                    </div>    
                </div>
                <div class="media_edit_area">
                    <div id="js_appmsg_editor">
                        <div class="appmsg_editor" style="margin-top: 0px;">
                            <div class="inner">
                                <div class="appmsg_edit_item">
                                    <label for="" class="frm_label">标题</label>
                                    <span class="frm_input_box"><input type="text" class="frm_input js_title" name="news_title" value="{$one_news_images.news_title}"/></span>
                                </div>
                                <div class="appmsg_edit_item">
                                    <label for="" class="frm_label">
                                        <strong class="title">作者</strong>
                                        <p class="tips l">（选填）</p>
                                    </label>
                                    <span class="frm_input_box"><input type="text" class="frm_input js_author" name="news_author" value="{$one_news_images.news_author}" /></span>
                                </div>
                                <div class="appmsg_edit_item">
                                    <label for="" class="frm_label">
                                        <strong class="title">封面</strong>
                                        <p class="js_cover_tip tips">（大图片建议尺寸：900像素 * 500像素）</p>
                                    </label>
                                    <div class="upload_wrap">
                                        <div class="upload_box">
                                        	<input type="hidden" name="news_img_path" id="news_img_path" value="{$one_news_images.news_img_path}"/>
                                            <div class="upload_area">
                                            <div class="btnfile">
									            <span>上传</span>
									            <input id="fileupload" type="file" name="mypic">
									        </div>
									        <div class="progress">
									    		<span class="bar"></span><span class="percent">0%</span >
											</div>
									        <div class="files">
									        	<b>({$image_path})</b><span class='delimg' rel="{$image_path}">删除</span>
									        </div>
									        <div id="showimg"><img src='{$one_news_images.news_img_path}' style='width:100px; height:100px;'></div>
                                        </div>&nbsp;
                                    </div>
                                    <p class="frm_tips">
                                        <label for="" class="frm_checkbox_label js_show_cover_pic selected">
                                            <input type="checkbox" name="is_show_article[]" style="margin-top: 3px; margin-right:10px; float: left;" value="{$one_news_images.is_show_article}" {if $is_show_article}checked=checked{/if} />
                                           		封面图片显示在正文中 
                                        </label>
                                    </p>
                                    <if condition="$one_news_images.news_zhaiyao neq null">
	                                    <div class="js_desc_area dn appmsg_edit_item" id="appmsg_zhaiyao">
											<label for="" class="frm_label">摘要</label>
											<span class="frm_textarea_box"><textarea class="js_desc frm_textarea" id="new_textarea_zhaiyao" name="news_zhaiyao">{$one_news_images.news_zhaiyao}</textarea></span>
										</div>
									<else />
										<p class="frm_tips" id="hide_zhaiyao">
	                                        <label for="" class="frm_checkbox_label js_show_cover_pic selected">
	                                           <a href="javascript:void(0);" id="show_zhaiyao" style="color: #459ae9; font-size: 14px;font-family:'微软雅黑'">添加摘要</a>
	                                        </label>
	                                    </p>
	                                    <div class="js_desc_area dn appmsg_edit_item" id="appmsg_zhaiyao" style="display: none;">
											<label for="" class="frm_label">摘要</label>
											<span class="frm_textarea_box"><textarea class="js_desc frm_textarea" id="new_textarea_zhaiyao" name="news_zhaiyao"></textarea></span>
										</div>
                                    </if>
                                </div>
                                <div id="js_ueditor" class="appmsg_edit_item content_edit">
                                    <label for="" class="frm_label">
                                        <strong class="title">正文</strong>
                                        <p class="tips">
                                            <em id="js_auto_tips">（自动保存：2014/08/08 16:20:12）</em>
                                            <div style="margin-top: 20px;float: left;"> 
                                            	<textarea name="content" id="content">{$one_news_images.news_content}</textarea>
                                            </div>
                                        </p>
                                    </label>
                                    <if condition="$one_news_images.news_href neq null">
	                                    <div class="js_desc_area dn appmsg_edit_item" id="appmsg_link">
											<label for="" class="frm_label">原文链接</label>
											<span class="frm_input_box"><input type="text" class="frm_input js_author" name="news_href" value="{$one_news_images.news_href}"/></span>
										</div>
                                    <else />
	                                    <p class="frm_tips" id="hide_link">
	                                       	<label for="" class="frm_checkbox_label js_show_cover_pic selected">
	                                          	<a href="javascript:void(0);" id="show_link" style="color: #459ae9; padding-top:10px;float:left;font-size: 14px;font-family:'微软雅黑'">添加原文链接</a>
	                                       	</label>
	                                    </p>
	                                    <div class="js_desc_area dn appmsg_edit_item" id="appmsg_link" style="display: none;">
											<label for="" class="frm_label">原文链接</label>
											<span class="frm_input_box"><input type="text" class="frm_input js_author" name="news_href"/></span>
										</div>
                                    </if>
                                </div>
                                <i class="arrow arrow_out" style="margin-top: 0px;"></i>
                                <i class="arrow arrow_in" style="margin-top: 0px;"></i>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tool_area">
                    <div class="tool_bar border tc">
                        <span id="js_submit" class="btn btn_input btn_primary"><button type="submit">保存</button></span>
                        <span id="js_preview" class="btn btn_input btn_default"><button>预览</button></span>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <script type="text/javascript">
	        KindEditor.ready(function(K) {
	        	var editor1 = K.create('textarea[name="content"]', {
	        		cssPath : '__PUBLIC__/admin/templates/plugins/code/prettify.css',
	        		uploadJson : '__PUBLIC__/lib/upload_json.php',
	        		width : "117%", //编辑器的宽度为70%
	        	    height : "360px", //编辑器的高度为100px
	        		fileManagerJson : '__PUBLIC__/lib/file_manager_json.php',
	        		items:['source', 'undo', 'redo',
	        		       'justifyleft', 'justifycenter', 'justifyright',
	        		       'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent','selectall',
	        		       'title', 'bold',
	        		       'italic', 'underline','image','removeformat','|', 'fullscreen'],
	        		allowFileManager : true,
	        		afterCreate : function() {
	        			var self = this;
	        			K.ctrl(document, 13, function() {
	        				self.sync();
	        				K('form[name=example]')[0].submit();
	        			});
	        			K.ctrl(self.edit.doc, 13, function() {
	        				self.sync();
	        				K('form[name=example]')[0].submit();
	        			});
	        		}
	        	});
	        	prettyPrint();
	        });
        	$(function(){
        		$(".js_title").bind("keyup", function (){
        			$("#new_title").text($(this).val());
        		});
        		$("#new_textarea_zhaiyao").bind("keyup", function(){
        			$(".appmsg_desc").text($(this).val());
        		});
        		$("#show_zhaiyao").bind("click", function(){
        			$("#hide_zhaiyao").hide();
        			$("#appmsg_zhaiyao").show();
        		});
        		$("#show_link").bind("click", function(){
        			$("#hide_link").hide();
        			$("#appmsg_link").show();
        		});
        	});
        	$(function () {
        		var bar = $('.bar');
        		var percent = $('.percent');
        		var showimg = $('#showimg');
        		var progress = $(".progress");
        		var files = $(".files");
        		var btn = $(".btnfile span");
        		$("#fileupload").wrap("<form id='myupload' action='{:U(\'ajaxUploadImg\')}' method='post' enctype='multipart/form-data'></form>");
        	    $("#fileupload").change(function(){
        			$("#myupload").ajaxSubmit({
        				dataType:  'json',
        				beforeSend: function() {
        	        		showimg.empty();
        					progress.show();
        	        		var percentVal = '0%';
        	        		bar.width(percentVal);
        	        		percent.html(percentVal);
        					btn.html("上传中...");
        	    		},
        	    		uploadProgress: function(event, position, total, percentComplete) {
        	        		var percentVal = percentComplete + '%';
        	        		bar.width(percentVal);
        	        		percent.html(percentVal);
        	    		},
        				success: function(data) {
        					files.html("<b>"+data.name+"("+data.size+"k)</b> <span class='delimg' rel='"+data.pic+"'>删除</span>");
        					var img = '{$serverUrl}'+"__PUBLIC__/data/files/news/"+data.pic;
        					showimg.html("<img src='"+img+"' style='width:100px; height:100px;'>");
        					$("#new_img_default").attr("src", img);
        					$("#news_img_path").val(img);
        					$(".appmsg_thumb").show();
        					btn.html("上传");
        				},
        				error:function(xhr){
        					btn.html("上传失败");
        					bar.width('0')
        					files.html(xhr.responseText);
        				}
        			});
        		});
        		
        		$(".delimg").live('click',function(){
        			var pic = $(this).attr("rel");
        			$.post("{:U('ajaxDeleteImg')}",{imagename:pic},function(msg){
        				if(msg==1){
        					files.html("删除成功.");
        					showimg.empty();
        					progress.hide();
        					$("#new_img_default").attr("src", "");
        					$(".appmsg_thumb").hide();
        					$(".default").show();
        				}else{
        					alert(msg);
        				}
        			});
        		});
        	});
        	</script>
        </script>
    </body>
</html>